﻿using Microsoft.AspNetCore.Mvc;
using MVC_System.DTO.Qualityduring;
using MVC_System.DTO.Reservoir;
using WMS_MAV;

namespace MVC_System.Controllers
{
    public class QualityduringController : Controller
    {
        protected readonly IConfiguration _configuration;

        public QualityduringController(IConfiguration configuration)
        {
            _configuration = configuration;
        }
        /// <summary>
        // 过程质检显示视图
        /// </summary>
        /// <returns></returns>
        public IActionResult QualityduringShow()
        {
            return View();
        }
        /// <summary>
        /// 过程质检列表
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> QualityShowsj(QualityShowDto dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.Token);
            string url = _configuration["Url"] + "LYH/api/Quality/ShowQuality?pageIndex=" + dto.pageIndex + "&pageSize=" + dto.pageSize + "&QualityNumber=" + dto.qualityNumber + "&productionlineNumber=" + dto.productionlineNumber+ "&QualityState="+dto.qualityState;
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        // 过程质检添加视图
        /// </summary>
        /// <returns></returns>
        public IActionResult QualityduringAdd()
        {
            return View();
        }
        /// <summary>
        /// 添加过程质检
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> QualityAdd(ReservoirAddDto dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.Token);
            string url = _configuration["Url"] + "LYH/api/Quality/CreateQuality";
            var response = await client.PostAsync(url, dto.Data);
            return Json(response);
        }
    }
}
